<?
if($_POST['str']!="") {
	$foto = $_POST['str'];
	$resource = imagecreatefromstring(base64_decode($foto));
	$width = imagesx($resource);
	$height = imagesy($resource);
	$aspect_ratio = $height/$width;
	$img = ImageCreateTrueColor($width,$height);
	$foto = $_SERVER[DOCUMENT_ROOT]."/test/test.jpg";
	imagecopyresampled($img,$resource,0,0,0,0,$width,$height,$width,$height);
	imagejpeg($img,$foto,80);
	imagedestroy($resource);
	$image = '<img src="/test/test.jpg" />';
}
?>
<html>
<head></head>
<body>
<form action="stringtoimage.php" method="POST">
<p><?=$image?></p>
<p>Stringa in base 64</p>
<p><textarea rows="25" cols="100" name="str"></textarea></p>
<p><input type="submit" value="CONVERTI"></p>
</form>
</body>
</html>